import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

const state = {
  pId: 0,
  king: 1,
  showType: '',
  checkList: [],
  fileList: [],
  fileSelectFlag: false,
}

const getters = {
  netPid(state) {
    return state.pId
  },
  netKing(state) {
    return state.king
  },
  netShowType(state) {
    return state.showType
  },
  netCheckedFile(state) {
    return state.checkList
  },
  netFileList(state) {
    return state.fileList
  },
  netFileSelectFlag(state) {
    return state.fileSelectFlag
  },
}

const actions = {
  setPid({ commit }, id) {
    commit('SETPID', id)
  },
  setKing({ commit }, king) {
    commit('SETKING', king)
  },
  setShowType({ commit }, showType) {
    commit('SETSHOWTYPE', showType)
  },
  selectFile({ commit }, fileList) {
    commit('SELECT_FILE', fileList)
  },
  setFileList({ commit }, fileList) {
    commit('SETFILELIST', fileList)
  },
  setFileSelectFlag({ commit }, flag) {
    commit('SETFILESELECTFALG', flag)
  },
}

const mutations = {
  SETPID: (state, d) => {
    state.pId = d
  },
  SETKING: (state, d) => {
    state.king = d
  },
  SETSHOWTYPE: (state, d) => {
    state.showType = d
  },
  SETFILELIST: (state, d) => {
    state.fileList = d
  },
  SELECT_FILE: (state, d) => {
    state.checkList = d
  },
  SETFILESELECTFALG: (state, d) => {
    state.fileSelectFlag = d
  },
}

export default {
  state,
  getters,
  actions,
  mutations,
}
